import { waitTimeOut, notifications } from '../../common.js'

// 自动填写登录信息
async function autoInputAccount({ companyInfo }) {
  await waitTimeOut(3000);
  if (!companyInfo || (!companyInfo.nationalTaxAccount && !companyInfo.nationalTaxId)) return;
  if ($('.alert_click_show').length === 0) return;
  if ($('.alert_click_show').attr('href') !== 'javascript:void(0)') return;
  let {
    nationalTaxId = '',
    nationalTaxAccount = '',
    nationalTaxUser = '',
    nationalTaxPass = '',
    taxStaffPhone = '',
  } = companyInfo;
  $('.alert_click_show').click();
  companyInfo = companyInfo || {};
  $('#shxydm_qy').val(nationalTaxId);
  $('#shxydm_qy').blur();
  $('#username_qy').val(nationalTaxAccount || nationalTaxUser);
  $('#username_qy').blur();
  $('#password_qy').val(nationalTaxPass);
  $('#password_qy').blur();
  setTimeout(() => {
    $('#sjhm_qy').val(taxStaffPhone);
  }, 1000)
}

export { autoInputAccount };